{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "什么是主成分分析\n",
    "    定义: 高维数据转化成低维数据的过程,再此过程中可能会舍弃原有的数据,创造新的变量\n",
    "    作用: 是数据维数压缩,尽可能降低原数据的维数(复杂度),损失少量信息\n",
    "    应用: 回归分析或者聚类分析当中\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<img src=\"1-09.jpg\">\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<img src=\"1-09.jpg\">"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1.28620952e-15  3.82970843e+00]\n",
      " [ 5.74456265e+00 -1.91485422e+00]\n",
      " [-5.74456265e+00 -1.91485422e+00]]\n"
     ]
    }
   ],
   "source": [
    "# 演示应用\n",
    "from sklearn.decomposition import PCA\n",
    "\n",
    "data = [[2,8,4,5],[6,3,0,8],[5,4,9,1]]\n",
    "\n",
    "# 实例化转换器类\n",
    "transfer = PCA(n_components=2)\n",
    "# n_components 降维的特征数\n",
    "# 调用fit_transform\n",
    "data_new = transfer.fit_transform( data )\n",
    "\n",
    "print( data_new )\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
